package pokemon;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

@SuppressWarnings("serial")
public class AbilityList extends ArrayList<Ability>
{
	public void calculateAbilities()
	{
		try 
		{
			String nextLine;
			BufferedReader pokeReader=new BufferedReader(new FileReader("abilityEffects.txt"));
			while((nextLine=pokeReader.readLine())!=null)
			{
				String result[]=nextLine.split(" ");
				if(result.length>1)
				{
					ArrayList<String> names=new ArrayList<String>();
					ArrayList<Double> mode=new ArrayList<Double>();
					names.add(result[1]);
					mode.add(Double.parseDouble(result[2]));
					if(result.length>=4)
					{
						names.add(result[3]);
						mode.add(Double.parseDouble(result[4]));
					}
					this.add(new Ability(result[0],names,mode));
				}
			}
		} 
		catch (Exception e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Ability getAbility(String name)
	{
		for(Ability abil:this)
		{
			if(abil.getName().equals(name))
			{
				return abil;
			}
		}
		return null;
	}
}

